package com.zhan.ielts.utils;

import java.io.File;
import java.io.FilenameFilter;

public class FileFilter implements FilenameFilter {

	@Override
	public boolean accept(File dir, String name) {
		File file = new File(name);
		String fileName = file.getName();
		return fileName.indexOf(type) != -1;
	}

	private String type;

	public FileFilter(String type) {
		this.type = type;
	}
	
	
	public static void main(String[] argv){
		
		String path = "/usr/local/webapps/ieltsFile/total";
		File file = new File(path);
		
		File[] oldQuestionFiles = file.listFiles(new java.io.FileFilter() {
			@Override
			public boolean accept(File pathname) {
				return pathname.getName().indexOf(".m4a") == -1;
			}
		});
		System.out.println("---------");
		
		for (int t = 0; t < oldQuestionFiles.length; t++) {
			System.out.println(oldQuestionFiles[t].getName());
			oldQuestionFiles[t].delete();
			
		}
		
	}
}
